package com.javafx.application;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

/**
 * TreeView控件练习
 */
public class Main4 extends Application {
    public void start(Stage primaryStage) throws Exception {

        StackPane root = new StackPane();
        Scene scene = new Scene(root,400,400);

        TreeItem treeItem = new TreeItem("基础图形",new Button("fdfd"));


        //添加子节点
        for(int i = 0;i < 5;i++){
            TreeItem item = new TreeItem("节点:" + i);
            treeItem.getChildren().add(item);
        }
        treeItem.setExpanded(true);

        //添加节点的功能
        ContextMenu menu = new ContextMenu();

        TreeView treeView = new TreeView(treeItem);
        treeView.setPrefWidth(200);
        root.getChildren().addAll(treeView);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
